package com.googlecode.rulio.rendering.html;

import com.googlecode.rulio.ExecutionReport;
import com.googlecode.rulio.rendering.Renderer;

public class HtmlExecutionReportRenderer implements Renderer<ExecutionReport> {
    MainRenderer renderer = new MainRenderer();

    public String render(ExecutionReport report) {
        StringBuilder builder = new StringBuilder();

        builder.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" xml:lang=\"en-US\">");
        builder.append("<head>");
        builder.append("<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></script>");
        builder.append("<script type=\"text/javascript\">\n" +
                "jQuery(document).ready(function() {\n" +
                "  jQuery(\".content\").hide();\n" +
                "  //toggle the componenet with class msg_body\n" +
                "  jQuery(\".heading\").click(function()\n" +
                "  {\n" +
                "    jQuery(this).next(\".content\").slideToggle(200);\n" +
                "  });\n" +
                "});\n" +
                "</script>");
        builder.append("<style type=\"text/css\"> \n" +
                "body {\n" +
                "\tmargin: 20px auto;\n" +
                "\tfont: 12px Verdana,Arial, Helvetica, sans-serif;\n" +
                "}\n" +
                ".layer1 {\n" +
                "margin: 0;\n" +
                "padding: 0;\n" +
                "width: 500px;\n" +
                "}\n" +
                " \n" +
                ".heading {\n" +
                "margin: 1px;\n" +
                "color: #000;\n" +
                "padding: 3px 10px;\n" +
                "cursor: pointer;\n" +
                "position: relative;\n" +
                "background-color:#FFBF47;\n" +
                "}\n" +
                ".matchedNotExecuted {\n" +
                "margin: 1px;\n" +
                "color: #000;\n" +
                "padding: 3px 10px;\n" +
                "cursor: pointer;\n" +
                "position: relative;\n" +
                "background-color:#888;\n" +
                "}\n" +
                ".notMatched {\n" +
                "margin: 1px;\n" +
                "color: #000;\n" +
                "padding: 3px 10px;\n" +
                "cursor: pointer;\n" +
                "position: relative;\n" +
                "background-color:lightgray;\n" +
                "}\n" +
                ".content {\n" +
                "padding: 5px 10px;\n" +
                "background-color:#fafafa;\n" +
                "}\n" +
                "p { padding: 5px 0; }\n" +
                "</style> ");
        builder.append("</head>");
        builder.append("<body>");
        builder.append("<table border='1' width='100%'>");
        builder.append("<tr><td>");

        builder.append(renderer.render(report));

        builder.append("</td></tr>");
        builder.append("</table>");
        builder.append("</body>");
        builder.append("</html>");


        return builder.toString();
    }

}
